package com.gohome.gohomechat.presenter;

import com.gohome.gohomechat.model.PersonalModel;
import com.gohome.gohomechat.model.entify.CurrentUser;
import com.gohome.gohomechat.model.modellistener.PersonalModelInterface;
import com.gohome.gohomechat.presenter.callback.PersonalCallBack;
import com.gohome.gohomechat.presenter.presenterlistener.PersonalPresenterInterface;
import com.gohome.gohomechat.ui.viewlistener.PersonalViewInterface;

/**
 * Created by dllo on 16/3/9.
 */
public class PersonalPresenter implements PersonalPresenterInterface {
    private PersonalViewInterface personalViewInterface;
    private PersonalModelInterface personalModelInterface;

    public PersonalPresenter(PersonalViewInterface personalViewInterface) {
        this.personalViewInterface = personalViewInterface;
        this.personalModelInterface = new PersonalModel();
    }

    @Override
    public void loadData() {
        personalViewInterface.showDialog();
        personalModelInterface.loadData(new PersonalCallBack() {
            @Override
            public void success(CurrentUser user) {
                personalViewInterface.showInfo(user);
                personalViewInterface.dismissDialog();
            }

            @Override
            public void failed() {
                personalViewInterface.dismissDialog();
            }
        });
    }
}
